<template>
    <div class="Tablesc">
        <el-table :data="workDatas" style="width: 100%"
            :header-cell-style="{ backgroundColor: '#f9f9f9', height: '56px' }">
            <el-table-column label="序号" prop="id" width="65" />
            <el-table-column label="姓名" prop="name" width="113" />
            <el-table-column label="类型" prop="types" width="99" />
            <el-table-column label="状态" prop="status" width="99" />
            <el-table-column label="证件号码" prop="idcard" />
            <el-table-column label="手机号码" prop="phone" />
            <el-table-column label="房间" prop="address" />
            <el-table-column label="操作">
                <template #default="scope">
                    <div style="color: #049fff;display: flex;justify-content: space-between;">
                        <div @click="handleshenhe">审核</div>
                        <div @click="handleEdit(scope.$index, scope.row)">编辑</div>
                        <div @click="handleDelete(scope.$index, scope.row)">删除</div>
                    </div>
                </template>
            </el-table-column>
        </el-table>
        <WorkPage />
    </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { useHomeStore } from '@/stores/HomeStore';
import { storeToRefs } from 'pinia';
import type { WorkData } from '@/types/WorkData';
import WorkPage from './Workpage.vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { useRouter } from 'vue-router'
const router = useRouter();
const homeStore = useHomeStore();
const { workDatas } = storeToRefs(homeStore);
const { getworktable, delworktable } = homeStore;
getworktable();


const handleEdit = (index: number, row: WorkData) => {
    router.push('/home/workbench/add')
}
const handleDelete = (index: number, row: any) => {
    ElMessageBox.confirm(
        '确认删除该条信息吗?',
        '提示',
        {
            confirmButtonText: '确认',
            cancelButtonText: '取消',
            type: 'warning',
        }
    )
        .then(() => {
            ElMessage({
                type: 'success',
                message: '删除成功',
            })
            delworktable(row.id)
        })
        .catch(() => {
            ElMessage({
                type: 'info',
                message: '取消删除',
            })
        })
}
const handleshenhe = () => {
    router.push('/home/Workbench/approval')
}
</script>

<style scoped>

</style>